package net.asfun.jvalog.util;


public class InputFilter {
	
	public static String escape(String str) {
		return str.replaceAll("&", "&amp;")
				.replaceAll(">", "&gt;")
				.replaceAll("<", "&lt;");
	}
	
	public static String breakline(String str) {
		return str.replaceAll("\\n", "<br />");
	}
	
	public static String pureText(String str) {
		return str.replaceAll("<.*?>", "");
	}
	
	public static String length(String str, int length) {
		if ( str.length() > length ) {
			return str.substring(0, length);
		}
		return str;
	}

}
